<?php
namespace common\models;

use Yii;
use yii\behaviors\TimestampBehavior;

/**
 * This is the model class for table "userfile".
 *
 * @property integer $id
 * @property integer $user_id
 * @property string $storage_hash
 * @property integer $created_at
 * @property integer $updated_at
 */
class Userfile extends \yii\db\ActiveRecord
{

    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'userfile';
    }

    /*
     * 产生创建日期和更新日期时间戳
     */
    public function behaviors()
    {
        return [
            [
                'class' => TimestampBehavior::className(),
                'createdAtAttribute' => 'created_at',
                'updatedAtAttribute' => 'updated_at'
            ]
        ];
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [
                [
                    'user_id',
                    'created_at',
                    'updated_at'
                ],
                'integer'
            ],
            [
                [
                    'storage_hash'
                ],
                'required'
            ],
            [
                [
                    'storage_hash'
                ],
                'string',
                'max' => 32
            ]
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'user_id' => '用户ID',
            'storage_hash' => '图片哈希',
            'created_at' => '创建日期',
            'updated_at' => '更新日期'
        ];
    }
}
